package com.heima.user.controller.v1;

import com.heima.model.common.constants.admin.AdminConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDTO;
import com.heima.user.service.ApUserRealnameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.RequestWrapper;

/**
 * @作者 itcast
 * @创建日期 2021/11/18 11:37
 **/
@RestController
@RequestMapping("api/v1/auth")
@Api(value = "实名认证审核controller",tags = "实名认证审核controller")
public class ApUserRealnameController {
    @Autowired
    ApUserRealnameService apUserRealnameService;

    @ApiOperation("根据状态查询实名认证信息")
    @PostMapping("list")
    public ResponseResult list(@RequestBody AuthDTO dto){
        return apUserRealnameService.loadListByStatus(dto);
    }

    @ApiOperation("审核失败")
    @PostMapping("authFail")
    public ResponseResult authFail(@RequestBody AuthDTO dto){
        return apUserRealnameService.updateStatusById(dto, AdminConstants.FAIL_AUTH);
    }

    @ApiOperation("审核通过")
    @PostMapping("authPass")
    public ResponseResult authPass(@RequestBody AuthDTO dto){
        return apUserRealnameService.updateStatusById(dto, AdminConstants.PASS_AUTH);
    }
}
